# Contributor: omni <omni+alpine@hack.org>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby-net-telnet
_gemname=net-telnet
pkgver=0.2.0
pkgrel=3
pkgdesc="A telnet client functionality for Ruby"
url="https://github.com/ruby/net-telnet"
arch="noarch"
license="BSD-2-Clause"
depends="ruby"
checkdepends="ruby-minitest ruby-rake"
makedepends="ruby-rdoc"
subpackages="$pkgname-doc"
source="https://github.com/ruby/net-telnet/archive/v$pkgver/ruby-net-telnet-$pkgver.tar.gz
	gemspec.patch
	"
builddir="$srcdir/$_gemname-$pkgver"
options="!check"  # FIXME: backport fixes for tests from project's repo

prepare() {
	default_prepare
	sed -i '/require .bundler/d' Rakefile
}

build() {
	gem build $_gemname.gemspec
}

check() {
	rake test
}

package() {
	local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"

	gem install \
		--local \
		--install-dir "$gemdir" \
		--ignore-dependencies \
		--document ri \
		--verbose \
		$_gemname

	# Remove unnessecary files
	cd "$gemdir"
	rm -rf build_info cache extensions plugins
}

doc() {
	pkgdesc="$pkgdesc (ri docs)"

	amove "$(ruby -e 'puts Gem.default_dir')/doc"
}

sha512sums="
a4473c42d33c10594c4445c29db73f4d611555710228cce263f7fc273e71140423dcbc2e89eec2a26f35f98de48aa72eca9f44cf0cd4626d702709963ce7b02d  ruby-net-telnet-0.2.0.tar.gz
fedd03416a65e54f06acbf762861d211f5374fa57febfe0278168d1067470a48c6c2b09938354cf12b1c1e5498855fa5003dc73f85bfbc9b2321447dca9ed608  gemspec.patch
"
